package com.fucai.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fucai.controller.vo.TuijianAddReqVO;
import com.fucai.controller.vo.TuijianQueryReqVO;
import com.fucai.entity.Fucai3dTuijian;
import com.fucai.service.Fucai3dTuijianService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 福彩3D推荐数据
 * @author: zhuchi
 * @create: 2025-06-17 10:40
 * @Version 1.0
 **/
@Api(tags = "福彩3D推荐数据")
@Slf4j
@RestController
@RequestMapping("/fucai/3d/tuijian")
public class Fucai3dTuijianController {

    @Resource
    private Fucai3dTuijianService fucai3dTuijianService;

    /**
     * 添加或更新推荐信息
     * @param reqVO
     * @return
     */
    @ApiOperation(value = "添加或更新推荐信息")
    @PostMapping("/addOrUpdateTuijianData")
    public String addOrUpdateTuijianData(@Validated @RequestBody TuijianAddReqVO reqVO){
        String result = fucai3dTuijianService.addTuijianData(reqVO);

        return result;
    }

    /**
     * 查询推荐数据
     * @param reqVO
     * @return
     */
    @ApiOperation(value = "查询推荐数据")
    @PostMapping("/queryTuijianData")
    public List<Fucai3dTuijian> queryTuijianData(@RequestBody TuijianQueryReqVO reqVO){
        LambdaQueryWrapper<Fucai3dTuijian> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (StringUtils.isNotBlank(reqVO.getTuijianQihao())){
            lambdaQueryWrapper.eq(Fucai3dTuijian::getTuijianQihao, reqVO.getTuijianQihao());
        }
        if (StringUtils.isNotBlank(reqVO.getTuijianRen())){
            lambdaQueryWrapper.eq(Fucai3dTuijian::getTuijianRen, reqVO.getTuijianRen());
        }
        List<Fucai3dTuijian> result = fucai3dTuijianService.list(lambdaQueryWrapper);

        return result;
    }


}
